<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script> 
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
		<!-- DWR -->
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	   	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>
  </head>
  
  <body>
  <div class="mainContainer">
    <div class="headerTitle">基础信息管理&nbsp;>>&nbsp;易耗品期初数据管理</div>
    
       <div class="dtreeDiv" id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0,-1,"广元电业局","ac/getAssetCard.action?FN=<s:property value='FN' />");
						for(var i=0; i<category.length; i++){
							//d.add(id, pid, name, url, title, target, icon, iconOpen, open);
							var size = category[i].catid.length;
							//catid 编号为 001 电子产品 001001 电脑产品 0010010001 台式机
							var url = "ac/bycatid.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
			</script>
		</div>
		
     	<div class="dataDivLeftHasTree">
     	
     	<table class="gridTable" id="tab" border="0" cellspacing="0" cellpadding="0">
			<tr class="operatorAction">
				<td>
					<input type="button" style="margin-left:2px;" id="imp" value="导入" onclick="impTable();" />
					<input type="button" style="margin-left:2px;" id="exp" value="导出" onclick="exportTable();" />
					<input type="button" style="margin-left:2px;" id="ref" value="刷新" onclick="refresh();"/>
					<input type="button" style="margin-left:2px;" id="add" value="新增" onclick="addAc();" />
					<input type="button" style="margin-left:2px;" id="update" value="修改" onclick="updateAc();" />
					<input type="button" style="margin-left:2px;" id="del" value="删除" onclick="deleteAll();" />
					<input type="button" style="margin-left:2px;" id="clock" value="锁定" onclick="hid()"/>
					<input type="button" style="margin-left:2px;" id="exit" value="退出" onclick="" />
					<input type="text" class="qryTxt" id="condition"/>
					<input type="button" style="margin-left:1px;" value="查询" onclick="queryCategory();"/>
					<font color="red"><s:property value="msg" /></font>
				</td>
			</tr><%-- 功能性操作行 --%>
			<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
					  			<!-- 数据表头 -->
						  <td><input id="checkAll" type="checkbox" /></td>
						  <!-- <td>编号</td> -->
						  <td>资产名称</td>
						  <td>资产简称</td>
						  <td>资产类别名称</td>
						  <td>申报原因</td>
						  <td>资金来源</td>
						  <td>申请部门</td>
						  <td>资产规格</td>
						  <td>生产日期</td>
						  <td>使用期限</td>
						  <td>预计停用日期</td>
						  <td>实际停用日期</td>
						  <td>单价</td>
						  <td>资产使用人</td>
						  <td>所在部门</td>
						  <td>凭证编号</td>
						  <td>凭证会计科目</td>
						  <td>计量单位</td>
						  <td>生产厂家</td>
						  <td>报废处置去向</td>
						  <td>报废残值</td>
						  <td>资产状态</td>
						</tr>
								          
								<!-- 数据 -->
						<s:iterator var="cat" value="pagination.dataList">
						<tr class="dataRow" id="<s:property value='#cat.acid'/>" ondblclick="updateAcByClick('<s:property value="#cat.acid" />')">
						  <td><input name="checkbox" type="checkbox" value="<s:property value="#cat.acid" />" /></td>
						  <!-- <td><s:property value="#cat.acid" /></td> -->
						  <td><s:property value="#cat.acname" /></td>
						  <td><s:property value="#cat.acanothername"/></td>
						  <td><s:property value="#cat.category.catid"/></td>
						  <td><s:property value="#cat.reportreason"/></td>
						  <td><s:property value="#cat.assetcomefrom"/></td>
						  <td><s:property value="#cat.reportdepartment"/></td>
						  <td><s:property value="#cat.category.catnorms"/></td>
						  <td><s:date name="#cat.producedate" format="yyyy-MM-dd hh:mm:ss"/></td>
						  <td><s:property value="#cat.lifetime"/></td>
						  <td><s:date name="#cat.planstopdate" format="yyyy-MM-dd hh:mm:ss" /></td>
						  <td><s:date name="#cat.actualstopdate" format="yyyy-MM-dd hh:mm:ss"/></td>
						  <td><s:property value="#cat.orderprice"/></td>
						  <td><s:property value="#cat.acuser"/></td>
						  <td><s:property value="#cat.depname"/></td>
						  <td><s:property value="#cat.orderid"/></td>
						  <td><s:property value="#cat.accountsubject"/></td>
						  <td><s:property value="#cat.category.catunit"/></td>
						  <td><s:property value="#cat.producer"/></td>
						  <td><s:property value="#cat.scrapmanage"/></td>
						  <td><s:property value="#cat.scrapworth"/></td>
						  <td><s:property value="#cat.acstatus"/></td>
						</tr>
						</s:iterator><%-- 数据循环结束 --%>
						<tr class="dataPager">
							<td colspan="21">
								<s:property value="pageLink" escapeHtml="false" />
							</td>
						</tr>
     				</table><%-- 数据表格结束 --%>
     			</td>	<%-- 数据 --%>
     		</tr>	<%-- 数据表格 --%>
     	</table>
    </div>
</div>
		<!-- 提交删除所有Id -->
  <form action="ac/delAssetCard.action" method="post" id="hiddenform">
  	<input type="hidden" id="hiddencatid" name="idArray"/>
  </form>
		<!-- 根据条件查询  
  <form action="queryCategory.action" method="post" id="hiddenform2">
  	<input type="hidden" id="hiddenCondition" name="conditionValue"/>
  </form>
   -->
	   <script type="text/javascript">

	    //刷新
	    function refresh(){
	    	window.location.href="ac/getAssetCard.action?FN=<s:property value='FN' />";
	    }	    
	    //添加分类
	    function addAc(){
	    	location.href = "ac/toUpdate.action?FN=<s:property value='FN' />";
	    }
	    //更新分类
	    function updateAc(){
		    var allId = $("input:checked");
		    if(allId.length == 1){
	    		location.href = "ac/getAssetCardById.action?FN=<s:property value='FN' />&acid="+allId[0].value;
		    }else{
			    alert("请勾选一个");
		    }
	    }
	    function updateAcByClick(id){
			window.location = "ac/getAssetCardById.action?FN=<s:property value='FN' />&acid="+id;
	    }
	    //根据Id删除
	    function deleteAc(catid){
	    	location.href = "ac/delAssetCard.action?FN=<s:property value='FN' />&acid="+catid;
	    }
	    //根据选择删除所有
	    function deleteAll(){
	    	var allId = document.getElementsByName("checkbox");
	    	var array = new Array(allId.length);
	    	var j = 0;
	    	for(var i=0; i<allId.length; i++){
	    		if(allId[i].checked == true){
	    			array[j] = allId[i].value;
	    			j++;
	    		}
	    	}
	    	//如果没有选中 不进行任何操作
	    	if(j == 0)
	    		return;
	    	var newArray = new Array(j);
	    	for(var i=0; i<j; i++){
	    		newArray[i] = array[i];
	    	}

	    	if(confirm("确定要删除本条记录吗？删除之后数据将不能恢复!")){
	    		document.getElementById("hiddencatid").value = newArray;
		    	document.getElementById("hiddenform").submit();
	    	 }
	    }// end deleteAll
	    
	    function queryAc(){
	    	//alert("开始查询");
	    	//根据选择条件查询结果
	    	$('#hiddenCondition').val($('#condition').val());
	    	$('#hiddenform2').submit();
	    }
	    
	    function exportTable(){
	    	//导出Excel表
	    	window.location.href="downloadCategory.action?FN=<s:property value='FN' />";
	    }

	    //超出库存数量的变色
	    function turnColor(){
			
	    }
		</script>
<script type="text/javascript">
	$(document).ready(function(){
		var tab = $(".dataTable");
		var dtreeDiv = $(".dtreeDiv");
		var imp = $("#imp");
		var exp = $("#exp");
		var ref = $("#ref");
		var add = $("#add");
		var update = $("#update");
		var del = $("#del");
		var exit = $("#exit");
		var clock = $("#clock");
		clock.click(function(){
			if(clock.val()=="锁定"){
				tab.hide();
				dtreeDiv.hide();
				imp.attr("disabled",true);
				exp.attr("disabled",true);
				ref.attr("disabled",true);
				add.attr("disabled",true);
				update.attr("disabled",true);
				del.attr("disabled",true);
				exit.attr("disabled",true);
				clock.val("解锁");
			}else{
				tab.show();
				dtreeDiv.show();
				imp.attr("disabled",false);
				exp.attr("disabled",false);
				ref.attr("disabled",false);
				add.attr("disabled",false);
				update.attr("disabled",false);
				del.attr("disabled",false);
				exit.attr("disabled",false);
				clock.val("锁定");
			}
		});
	});
</script>
  </body>
</html>